<?
    class Principio_Model_Spa
    {
        private $id;
        private $mac;
        private $serial;
        private $company_id;
        private $ip;
        private $last_prov;
        private $last_firmware;
        private $prov_status;
        private $last_prov_attempt;
        private $last_prov_msg;
        private $account_list;
        private $model_type;

        public function __construct(Principio_Model_Type $model_type, &$values = null)
        {
            if (is_null($values))
            {
                $this->id = -1;
                $this->mac = "";
                $this->serial = "";
                $this->company_id = -1;
                $this->ip = "";
                $this->last_prov = "0000:00:00 00-00-00";
                $this->last_firmware = "";
                $this->prov_status = "";
                $this->last_prov_attempt = "0000:00:00 00-00-00";
                $this->last_prov_msg = "";
            }
            else
            {
                $this->id = (isset($values['id']) ? $values['id'] : -1);
                $this->mac = $values['mac'];
                $this->serial = $values['serial'];
                $this->company_id = $values['company_id'];
                $this->ip = $values['ip'];
                $this->last_prov = $values['last_prov'];
                $this->last_firmware = $values['last_firmware'];
                $this->prov_status = $values['prov_status'];
                $this->last_prov_attempt = $values['last_prov_attempt'];
                $this->last_prov_msg = $values['last_prov_msg'];
            };

            $this->model_type = $model_type;

            $this->account_list = array();
            for ($i = 0; $i < $model_type->getExts(); $i++)
                $this->account_list[$i] = new Principio_Model_Account();
        }


        public function getID()
        {
            return $this->id;
        }


        public function setID($id)
        {
            $id_ = intval($id);
            if ($id_ < 1)
                return false;

            $this->id = $id_;
            return $this;
        }


        public function getMAC()
        {
            return $this->mac;
        }

        public function setMAC($MAC)
        {
            $this->mac = $MAC;
            return $this;
        }


        public function getSerial()
        {
            return $this->serial;
        }


        public function setSerial($serial)
        {
            $this->serial = $serial;
            return $this;
        }


        public function getCompanyID()
        {
            return $this->company_id;
        }


        public function setCompanyID($company_id)
        {
            $company_id_ = intval($company_id);
            if ($company_id_ < 1)
                return false;

            $this->company_id = $company_id_;
            return $this;
        }


        public function getTypeID()
        {
            return $this->model_type->getID();
        }


        public function getIP()
        {
            return $this->ip;
        }


        public function setIP($IP)
        {
            $this->ip = $IP;
            return $this;
        }


        public function getLastProv()
        {
            return $this->last_prov;
        }


        public function setLastProv($last_prov)
        {
            $this->last_prov = $last_prov;
            return $this;
        }


        public function getLastFirmware()
        {
            return $this->last_firmware;
        }

        public function setLastFirmware($last_firmware)
        {
            $this->last_firmware = $last_firmware;
            return $this;
        }

        public function getProvStatus()
        {
            return $this->prov_status;
        }

        public function setProvStatus($prov_status)
        {
            $this->prov_status = $prov_status;
            return $this;
        }


        public function getLastProvAttempt()
        {
            return $this->last_prov_attempt;
        }


        public function setLastProvAttempt($last_prov_attempt)
        {
            $this->last_prov_attempt = $last_prov_attempt;
            return $this;
        }


        public function getLastProvMsg()
        {
            return $this->last_prov_msg;
        }


        public function setLastProvMsg($last_prov_msg)
        {
            $this->last_prov_msg = $last_prov_msg;
            return $this;
        }


        public function setModelAccount($index, Principio_Model_Account $model_account)
        {
            $index_ = intval($index);
            if (count($this->account_list) > $index_)
            {
                $this->account_list[$index_] = $model_account;
            };

            return $this;
        }


        public function getModelAccount($index)
        {
            $index_ = intval($index);
            if (count($this->account_list) > $index_)
            {
                return $this->account_list[$index_];
            }
            else
                throw new Exception("if (".count($this->account_list)." > ".$index_.")");
        }


        public function getModelType()
        {
            return $this->model_type;
        }
    }
?>